package com.powernode.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 内容:
 * 作者: cy
 */
@EnableConfigurationProperties(AliSmsProperties.class)
@Configuration
public class AliSmsAutoConfiguration {

    @Autowired
    private AliSmsProperties aliSmsProperties;

    @Bean
    public IAcsClient acsClient() throws ClientException {
        //初始化ascClient,暂时不支持多region（请勿修改）
        IClientProfile profile = DefaultProfile.getProfile(aliSmsProperties.getRegion(), aliSmsProperties.getAccessKeyId(),
                aliSmsProperties.getAccessKeySecret());
        DefaultProfile.addEndpoint(aliSmsProperties.getRegion(), aliSmsProperties.getRegion(), aliSmsProperties.getProduct(), aliSmsProperties.getDomain());
        return new DefaultAcsClient(profile);
    }


}
